package tourist.springboot.service.impl;

import tourist.springboot.domain.TouristAttraction;
import tourist.springboot.domain.TouristaAttractionRepository;
import tourist.springboot.service.TouristAttractionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  TouristAttraction 业务层实现
 *
 * Created by wangzg on 30/09/2017.
 */
@Service
public class TouristAttractionServiceImpl implements TouristAttractionService {

    @Autowired
    TouristaAttractionRepository touristaAttractionRepository;

    @Override
    public List<TouristAttraction> findByIds(List<String> ids) {
        return touristaAttractionRepository.findAllById(ids);
    }

    @Override
    public List<TouristAttraction> findAll() {
        return touristaAttractionRepository.findAll();
    }

    @Override
    public TouristAttraction insert(TouristAttraction touristAttraction) {
        return touristaAttractionRepository.save(touristAttraction);
    }

    @Override
    public TouristAttraction update(TouristAttraction touristAttraction) {
        return touristaAttractionRepository.save(touristAttraction);
    }

    @Override
    public TouristAttraction delete(String id) {
        TouristAttraction touristRoute = touristaAttractionRepository.findById(id).get();
        touristaAttractionRepository.delete(touristRoute);
        return touristRoute;
    }

    @Override
    public TouristAttraction findById(String id) {
        return touristaAttractionRepository.findById(id).get();
    }
}
